<template>
  <iframe :id="id" ref="iframe" :src="url" frameborder="0" width="100%" :height="height" scrolling="auto" />
</template>

<script>
export default {
  name: 'IframeVIew',
  data() {
    return {
      height: '',
      url: '',
      id: ''
    };
  },
  watch: {
    $route() {
      this.goUrl();
    }
  },
  created() {
    this.goUrl();
  },
  updated() {
    this.goUrl();
  },
  mounted() {
    this.height = this.$refs.iframe.parentNode.offsetHeight;
  },
  methods: {
    /** 获取url加载内容 */
    goUrl() {
      const { url } = this.$route.meta;
      this.id = this.$route.path;
      if (url !== null && url !== undefined) {
        this.url = url;
      }
    }
  }
};
</script>
